package Lesson8;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

import java.util.concurrent.TimeUnit;

/**
 * Created by trimmm on 24.02.15.
 */
public class FirstTC {
    public static void main(String[] args) {
        WebDriver driver = new FirefoxDriver();
        driver.manage().window().maximize();
        driver.manage().timeouts().implicitlyWait(1000, TimeUnit.SECONDS); //default setting for waiting all web elements

        driver.get("https://ankiweb.net");

        WebElement fieldEmail = driver.findElement(By.xpath(".//*[@id='email']"));
        fieldEmail.clear();
        fieldEmail.sendKeys("selenium-2@mail.ua");

        WebElement fieldPassword = driver.findElement(By.xpath(".//*[@id='pass']"));
        fieldPassword.clear();
        fieldPassword.sendKeys("qwe123456");

        WebElement buttonLogin = driver.findElement(By.xpath(".//*[@value='Login']"));
        buttonLogin.click();


        if (driver.getCurrentUrl().equals("https://ankiweb.net/study/")){
            System.out.println("Test pass");
        }else{
            System.out.println("Test failed");
        }
/*
            try {
                driver.findElement(By.xpath(""));
            } catch (Exception e){
                System.out.println("test fail");
            }
*/
        driver.quit();

    }
}
